package function

import scala.collection.mutable.ListBuffer

class List_Test {
  def listTest(): Unit = {
    val list1: List[Int] = List(1, 2, 3)
    val list2: List[Int] = List(4, 5, 6)
    val list4:List[String]="jonny"::"amily"::Nil
    val list3: List[Any] =list4:::list1 ::: list2
    println(list3)
    println(list3(0))
    println(list3.head)
    println(list3.tail)
    println(list3.init)
    val add: List[Any] = list3.+:("拉拉")
    println(add)
  }
  def listBuffer():Unit={
    val list1:ListBuffer[Int]=ListBuffer(1,2,3)
    val list2:ListBuffer[String]=ListBuffer("jonny","amily")
    list2.insert(0,"拉拉")
    list2.remove(0,2)
    println(list2)
  }


}

object List_Test {
  def main(args: Array[String]): Unit = {
    val list1: List[Int] = List(1, 2, 3)
    val list2: List[Int] = 1 :: 2 :: 3 :: 4 :: Nil
    val list: List[Any] = list1 :: list2
    val list3: List[Int] = list1 ::: list2
    val ints: List[Int] = list2 intersect list1
    val map = Map("a" -> 1, 1 -> "W")
    println("啦啦啦"+ints)
    println(list2.reverse)
    for(elem<-list3.sliding(3,3)){
      println(elem)
    }
    
    println(list1)
    println(list2)
    println(list)
    println(list3)
    println(list3.takeRight(1))
    println(list3.apply(2))
    val list4: List[Int] = List(1, 23, 4)
    println("================")
    val test = new List_Test()
    test.listTest()
    println("=====================")
    test.listBuffer()

  }
}
